<template>
	<view>
		<view>鲁班上门</view>
		<view>
			<image src="/static/register/icon.png" class="logo"></image>
		</view>
		<view>
			<form @submit="onSubmit">
				<view class="title">输入手机号</view>
				<input class="uni-input" focus placeholder="手机号" v-model="phone" />
				<button class="mini-btn" type="primary" size="mini" @click="getCode()">获取验证码</button>
				<view class="title">输入验证码</view>
				<input class="uni-input" focus placeholder="验证码" v-model="code" />
				<view class="title">输入密码</view>
				<input class="uni-input" password focus placeholder="密码" v-model="password" />
				<button form-type="submit" type="primary">注册</button>
			</form>
			<button class="mini-btn" type="default" size="mini" @click="gotoLogin()">我要登录</button>

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				phone: '',
				code: '',
				password: ''

			}
		},
		onLoad() {

		},
		methods: {
			gotoLogin() {
				uni.navigateTo({
					url: "/pages/index/login"
				})
			},
			onSubmit() {
				console.log("gogogo");
				uni.request({
					url: 'http://120.46.197.40:8080/api/user/userLogin',
					method: 'POST',
					data: {
						"code": this.code,
						"password": this.password,
						"phone": this.phone,
						"type": "1",
					},
					header: {
						'content-type': 'application/x-www-form-urlencoded'
					},
					success: (res) => {
						console.log(res);
						//this.text = 'request success';
					}
				});
				console.log("alalal");
			},
			getCode() {
				uni.request({
					url: 'http://120.46.197.40:8080/api/user/userSendMessage',
					method: 'POST',
					data: {
						phone: this.phone,
						type: "1"
					},
					header: {
						'content-type': 'application/x-www-form-urlencoded'
					},
					success: (res) => {
						console.log(this.phone);
						console.log(res);
						//this.text = 'request success';
					}
				});
			}
		}
	}
</script>

<style>
	.logo {
		width: 400rpx;
		height: 100rpx;
	}
</style>
